package org.graduates.webapp.actions.course;

import java.util.Date;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.graduates.webapp.actions.BaseAction;
import org.projects.graduates.domain.HomeworkComment;

/**
 * 评论某次作业
 * 
 * @author zjzhai
 * 
 */
@Action(results = { @Result(name = "input", type = "json"), 
		@Result(name = "success", type = "json",
		params={"includeProperties","success, comment, comment.id," +
				" comment.content, comment.time,comment.handin, comment.handin.id" +
				" ,comment.person, comment.person.id, comment.person.showName"}) })
public class CommentHomeworkAction extends BaseAction {

	private static final long serialVersionUID = -3408995909410314744L;

	private boolean success = false;

	private HomeworkComment comment;

	
	public String execute() {

		if (null == comment || null == comment.getHandin()) {
			return INPUT;
		}
		comment.setTime(new Date());
		comment.setPerson(getCurrentPerson());
		this.gradApplication.save(comment);

		success = true;

		return SUCCESS;
	}

	public boolean isSuccess() {
		return success;
	}

	public HomeworkComment getComment() {
		return comment;
	}

	public void setComment(HomeworkComment comment) {
		this.comment = comment;
	}

}
